Learn R Programming

haplotypes (version 1.1.2)

[-methods: Extract or replace parts of an object of class Dna

Description

Operators acting on sequence matrix to extract or replace parts.

Usage

# S4 method for Dna
[(x, i, j, as.matrix = TRUE)
# S4 method for Dna
[(x, i, j)<- value

Value

returns an object of class matrix or Dna.

Arguments

x

an object of class Dna

i, j

elements to extract or replace.

as.matrix

boolean; If TRUE, function returns a matrix, else, function returns an object of class Dna.

value

a character vector or a character matrix.

Methods

signature(x = "Dna", i = "ANY", j = "ANY", drop = "ANY")

Author

Caner Aktas, caktas.aca@gmail.com

See Also

Dna

Examples

Run this code

data("dna.obj")
x<-dna.obj

## Extract parts.
# a matrix object
x[1:2,1:3]

# a Dna object, as.dna(x[1:2,1:3]) gives the same result
x[1:2,1:3,as.matrix=FALSE] 
  
## Replace parts.
#"G" "C"
x[1,1:2] 	
x[1,1:2]<-c("A","T")
x[1,1:2]



Run the code above in your browser using DataLab